package 人类;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class TestPerson {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String name1,name2,name3;
        int age1,age2,age3;
        name1 = input.nextLine();
        age1 = input.nextInt();
        input.nextLine();
        name2 = input.nextLine();
        age2 = input.nextInt();
        input.nextLine();
        name3 = input.nextLine();
        age3 = input.nextInt();
        ArrayList<Person1> personList1 = new ArrayList<>();
        personList1.add(new Person1(name1,age1));
        personList1.add(new Person1(name2,age2));
        personList1.add(new Person1(name3,age3));
        Collections.sort(personList1);
        System.out.println("Sort by name:");
        for(Person1 person: personList1)
            System.out.println(person.getName()+" "+person.getAge());
        ArrayList<Person2> personList2 = new ArrayList<>();
        personList2.add(new Person2(name1,age1));
        personList2.add(new Person2(name2,age2));
        personList2.add(new Person2(name3,age3));
        Collections.sort(personList2);
        System.out.println("Sort by age:");
        for(Person2 person: personList2)
            System.out.println(person.getName()+" "+person.getAge());
        ArrayList<Person3> personList3 = new ArrayList<>();
        personList3.add(new Person3(name1,age1));
        personList3.add(new Person3(name2,age2));
        personList3.add(new Person3(name3,age3));
        Collections.sort(personList3);
        System.out.println("Sort by age and name:");
        for(Person3 person: personList3)
            System.out.println(person.getName()+" "+person.getAge());
    }
}